﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Abhiruchi_Phase1.BAL_DAL.Biometric_DAL
{
    class BioRegistrationInfoDAL
    {
        static SqlConnection myCon = new SqlConnection(App.ConnectionString);
        static SqlCommand myCom = new SqlCommand();
        public static DataTable GetEmpDetails(int pType)
        {
            LoadBasicComm();
            DataTable mydt = new DataTable();
            myCom.Parameters.AddWithValue("@int_ptype", pType);
            SqlDataAdapter myadp = new SqlDataAdapter(myCom);
            myadp.Fill(mydt);
            return mydt;

        }
        private static void LoadBasicComm()
        {
            // DataTable mydt = new DataTable();
            myCom.Parameters.Clear();
            myCom.Connection = myCon;
            myCom.CommandText = "sp_Get_Set_PE_CE_BiometricInfo";
            myCom.CommandType = CommandType.StoredProcedure;
            //return mydt;
        }

        internal static void InsetEmpBioDetails(int pType, string empID, int fingerID, int impressnNo, byte[] bytData, string textData, int scanerID, DateTime dateOfScan)
        {
            LoadBasicComm();
            myCon.Open();
            myCom.Parameters.AddWithValue("@int_ptype", pType);
            myCom.Parameters.AddWithValue("@vc_eid", empID);
            myCom.Parameters.AddWithValue("@int_fingerID", fingerID);
            myCom.Parameters.AddWithValue("@int_impressionNo", impressnNo);
            myCom.Parameters.AddWithValue("@binary_biometricBinaryData", bytData);
            myCom.Parameters.AddWithValue("@vc_biometricTextData", textData);
            myCom.Parameters.AddWithValue("@int_scannerID", scanerID);
            myCom.Parameters.AddWithValue("@datetime_dateOfScan", dateOfScan);
            myCom.ExecuteNonQuery();
            myCon.Close();
        }
        internal static DataTable GetSpecEmpDetails(int pType, string empID)
        {
            LoadBasicComm();
            DataTable mydt = new DataTable();
            myCom.Parameters.AddWithValue("@int_ptype", pType);
            myCom.Parameters.AddWithValue("@vc_eid", empID);
            SqlDataAdapter myadp = new SqlDataAdapter(myCom);
            myadp.Fill(mydt);
            return mydt;
        }

        internal static void DeleteEmpImpression(int pType, string empID)
        {
            LoadBasicComm();
            myCon.Open();
            myCom.Parameters.AddWithValue("@int_ptype", pType);
            myCom.Parameters.AddWithValue("@vc_eid", empID);
            myCom.ExecuteNonQuery();
            myCon.Close();
        }
    }
}
